<?php
require_once ROOT_APPLICATION_MODULE_BACKEND_MODELS.DS.'Model_Article_Type.php';

class Zend_View_Helper_ListArticles
{
    public function listArticles($view,$baseUrl,$paginator)
    {
        $strList = '';
        $items = 0;

        foreach ($paginator as $rec)
        {
            $strList .=  '<tr class=row'.$rec['id'].'>';
            $strList .= '<td align="center"><input type="checkbox" name="chkid" onclick="checkOneItem(document.formIndex)" value="'.$rec['id'].'" /></td>';

            $mdArticleType = new Model_Article_Type();
            $articleType = $mdArticleType->_getByKey($rec['article_types_id']);

            if($view->langType == 'vn')
            {
                $strList .= '<td align="left">'.$rec['title_vn'] .'</td>';
                $strList .= '<td>'.$articleType->name_vn.'</td>';
            }
            else
            {
                $strList .= '<td align="left">'.$rec['title_en'] .'</td>';
                $strList .= '<td>'.$articleType->name_en.'</td>';
            }

            $strList .= '<td align="left">'.date_format(date_create($rec['created_date']),'d-m-Y h:i:s') .'</td>';
            $strList .= '<td align="left">'.date_format(date_create($rec['updated_date']),'d-m-Y h:i:s') .'</td>';

            if ($rec['active'] == ACTIVE)
                    $strList .= '<td align="center"><img class= "action" src="'. $baseUrl.'/public/media/images/default/publish.png" border="0" alt="active" title="publish"></td>';
            else
                    $strList .= '<td align="center"><img class= "action" src="'. $baseUrl.'/public/media/images/default/unpublish.png" border="0" alt="disable" title="publish"></td>';

            $strList .= '<td align="center"  scope="col">';
            $strList .= '<a href="'. $baseUrl .'/backend/article/edit/id/'.$rec['id'] . '"><img class= "action" src="'. $baseUrl.'/public/media/images/default/edit.png" border="0" alt="Edit"></a>&nbsp;&nbsp;&nbsp;';
            $strList .= '<a href="javascript:delList('.$rec['id']. ')"><img class= "action" src="'. $baseUrl.'/public/media/images/default/delete.png" border="0" alt="Delete"></a>';
            $strList .='</td> </tr>';
            $items++;
        }
        echo $strList;
    }
}